<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <title>忘记密码</title>
    <link rel="stylesheet" href="../../css/reset.css" />
    <style>
        body {
            width: 100%;
            background-color: #fff;
            font-size: 0.26rem;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: Helvetica;
            color: #333333;
            height: auto;
        }

        .uppicture {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
        }

        .uppicture div {
            margin-bottom: 0.35rem;
        }

        .nextbutton {
            width: 6.84rem;
            height: 0.9rem;
            line-height: 0.9rem;
            text-align: center;
            background-color: #ffd203;
            outline: none;
            border: none;
            border-radius: 0.1rem;
            margin-left: calc((100% - 6.84rem) / 2);
            font-size: 0.28rem;
        }

        .tips {
            height: 1rem;
            line-height: 1rem;
            width: 100%;
            padding: 0 0.3rem;
            box-sizing: border-box;
        }

        #getSaftCode {
            flex: 1;
            height: 0.8rem;
            outline: none;
            border: none;
            font-size: 0.26rem;
        }

        #getMessage {
            outline: none;
            border: none;
            width: 2rem;
            height: 0.68rem;
            border-radius: 0.05rem;
            background-color: #ffd203;
            font-size: 0.26rem;
        }
    </style>

</head>

<body>
    <div style="width: 100%;padding:0 0.28rem;box-sizing: border-box;border-top: 0.2rem solid #f7f7f7;">
        <div class="showCode"
            style="height: 1.08rem;display: flex;display: -webkit-flex;justify-content: space-between;align-items: center;border-bottom: 1px solid #e2e2e2;">
            <span style="display: block;width:1.8rem;">
                手机验证码
            </span>
            <input type="number" oninput="if(value.length>6)value=value.slice(0,6)" pattern="[0-9]*" id="getSaftCode"
                onkeyup="this.value=this.value.replace(/\D/g, '')" placeholder="请输入验证码">
            <button id="getMessage">
                获取验证码
            </button>
        </div>
    </div>
    <p class="tips">请上传手持身份证原件正面和个人签字</p>
    <div class="uppicture">
        <div class="force">
            <img src="../../image/zhadadsx.png" style="width:5.16rem;height: 3.44rem;" id="idCardfront" data-path=""
                data-flag="idCardfront" />
        </div>
        <div style="padding: 0 0.3rem;box-sizing: border-box;">
            <p style="line-height: 0.45rem;">
                1. 身份证上所有新清晰可见，照片需免冠，建议未化妆。手持证件人五官清晰，照片内容真实有效，不得做任何修改。</br>
                2. 个人手写的内容包含“人人矿场”、个人签名和“当前日期”，字迹工整，不得涂改。</br>
                仅支持JPG和PNG图片格式，图片大小小于2M。</br>
                注：为保护用户隐私，本照片仅用于找回交易密码
            </p>
        </div>
    </div>
    <button class="nextbutton">提交</button>
    <p style="color: #ff9c9c;margin-top: 0.4rem;padding-left: 0.3rem;box-sizing: border-box;font-size: 0.24rem;">
        温馨提示：找回密码申请提交后1-3个工作日将收到处理结果
    </p>
    <script src="../../script/autosize.js"></script>
    <script src="../../script/jquery_three_two_one.js"></script>
    <script src="../../script/app.js"></script>
    <script>
        apiready = function () {
            var app = new APP();
            var account = app.getAccount();
            app.headerMap();
            var imgWidth = app.W * 0.85;
            var imgHeight = app.accDiv(imgWidth, 1.58);
            var typeChooseNew = "idcard";
            var getCnySms, isCnyCaptcha = 0;
            //更换头像
            function openPirtrue(thiz) {
                app.sheet({
                    buttons: ["拍照", "相册"],
                    cancelTitle: "取消"
                }, function (ret, err) {
                    app.trigger("selectPic");
                    var index = ret.buttonIndex;
                    app.log("index", index);
                    if (index == 1) {
                        //拍照
                        app.shootPic(function (ret, err) {
                            app.log("shoot", ret);
                            // 图片裁剪
                            if (ret && ret.data) {
                                app.openImgHandle({
                                    type: typeChooseNew,
                                    flag: $(thiz).data("flag"),
                                    srcPath: ret.data,
                                    dimension: [imgWidth, imgHeight]
                                });
                            }
                        });
                        return;
                    }
                    if (index == 2) {
                        //相册
                        app.getPic(function (ret, err) {
                            // 图片裁剪
                            if (ret && ret.data) {
                                app.log("get", ret);
                                app.openImgHandle({
                                    type: typeChooseNew,
                                    flag: $(thiz).data("flag"),
                                    srcPath: ret.data,
                                    dimension: [imgWidth, imgHeight]
                                });
                            }
                        });
                    }
                }
                );
            };
            $("#idCardfront").click(function () {
                var thiz = this;
                openPirtrue(thiz);
            });

            function getCodeCallback() {
                app.countDown(60, function (value) {
                    if (value.time != 0) {
                        $("#getMessage").text(value.time + "s");
                    } else {
                        $("#getMessage").text("重新获取").attr("disabled", false).bind("click");
                    }
                });
                app.getSmslogin({
                    blackBox: isCnyCaptcha == 1 ? _fmOpt.getinfo() : "",
                    yzm_token: getCnySms
                }, function (ret) {
                    if (ret.code == 200) {
                        app.toast("发送成功");
                    } else {
                        app.toast(ret.message);
                    }
                })
            }


            //CNY 同盾插件初始化
            _fmOpt = {
                display: 'bind', //popup方式渲染验证码
                container: '#getMessage', //验证码button渲染的目标DOM，自动展现方式下必需，详情见后文
                area: '', //对于custom模式，弹出窗口的加载容器，详情见后文
                partner: "renrenkj",
                appName: "renrenkj_h5",
                width: "",
                height: "",
                fmb: true,
                initialTime: new Date().getTime(),
                token: "renrenkj" + "-" + new Date().getTime() + "-" + Math.random().toString(16).substr(2),
                env: 1,
                getinfo: function () {
                    return "e3Y6ICIyLjUuMCIsIG9zOiAid2ViIiwgczogMTk5LCBlOiAianMgbm90IGRvd25sb2FkIn0=";
                }
            };
            var fm = document.createElement('script');
            fm.type = 'text/javascript';
            fm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'static.tongdun.net/captcha/main/tdc.js?ver=1.0&t=' + (new Date().getTime() / 600000).toFixed(0);
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(fm, s);
            _fmOpt.beforeValidate = function () {
                $("#getMessage").attr("disabled", true).unbind("click");
                app.checkIsMechine("sms", function (ret, err) {
                    if (ret.code == 200) {
                        isCnyCaptcha = ret.data;
                        if (isCnyCaptcha == 1) {
                            _fmOpt.onSuccess = function (validateToken) {
                                if (validateToken) {
                                    getCnySms = validateToken;
                                    getCodeCallback();
                                } else {
                                    _fmOpt.reset();
                                }
                            };
                            return true;
                        } else {
                            getCodeCallback();
                            return false
                        }
                    }
                })
                return true
            }
            _fmOpt.onClose = function (params) {
                $("#getMessage").text("获取验证码").attr("disabled", false).bind("click");
            }
            app.listen("compress_image_success", function (ret, err) {
                app.log("压缩事件chankan", JSON.stringify(ret));
                // app.log("压缩事件", ret.value.imgUrl);
                if (ret.value.flag && ret.value.imgUrl) {
                    var retCopy = ret;
                    // 开始转菊花
                    app.uploadImg(ret.value.imgUrl, function (ret) {
                        if (ret.code == 200) {
                            if (ret.data.files.url) {
                                $("#" + retCopy.value.flag).attr("data-path", ret.data.files.path).attr("src", ret.data.files.url);
                            }
                        } else {
                            app.toast(ret.message);
                        }
                    })
                }
            });
            $(".nextbutton").on("click", function () {
                if (!$("#getSaftCode").val().trim()) {
                    app.toast("请输入验证码");
                    return
                }
                if ($("#idCardfront").attr("data-path") == "") {
                    app.toast("请上传证件图片");
                    return
                }
                var values = {
                    token: account.token,
                    photo: $("#idCardfront").attr("data-path"),
                    smscaptcha: $("#getSaftCode").val().trim()
                };
                app.ajaxPro({
                    url: "member/reset-pwd",
                    values: values,
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        app.toast("提交成功,等待审核");
                        app.trigger("forgetPass");
                        setTimeout(function () {
                            app.closeW(api.pageParam.pageName);
                        }, 1000)
                    } else {
                        app.toast(ret.message);
                    }
                })
            });
            app.listen("commit_successful", function () {
                app.closeW(api.pageParam.pageName);
            });
        };
    </script>
</body>

</html>